package com.yinhai.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;

import com.yinhai.photo.utils.Photo;

public class SystemSetupClearTalkInfoActivity extends Activity implements
		OnClickListener {
	ImageView backIv;
	private RadioGroup genderGroup = null;
	private RadioButton rb_setup_no, rb_setup_yes;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.systemsetupcleartalkinfo);


		genderGroup = (RadioGroup) findViewById(R.id.protectRG);
		rb_setup_no = (RadioButton) findViewById(R.id.protectRG_no);
		rb_setup_yes = (RadioButton) findViewById(R.id.protectRG_yes);

		backIv = (ImageView) findViewById(R.id.btn_back);
		backIv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				/*
				 * SharedPreferences preferences =
				 * SystemSetupClearTalkInfoActivity
				 * .this.getSharedPreferences(LoginCon.LOGIN_CONFIG,
				 * Context.MODE_PRIVATE); String setuppwdstr =
				 * preferences.getString(Contact.LOCAL_LOGIN_PWD, "");
				 * if(rb_setup_yes.isChecked() && setuppwdstr.length()<4){
				 * Toast.makeText(SystemSetupClearTalkInfoActivity.this,
				 * "请设置4位本机密码，并按下设置按钮！", Toast.LENGTH_SHORT).show(); }else{
				 * onBackPressed(); }
				 */
				onBackPressed();
			}
		});

		genderGroup
				.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
					@Override
					public void onCheckedChanged(RadioGroup group, int checkedId) {
						// TODO Auto-generated method stub
						if (checkedId == rb_setup_yes.getId()) {
							
							Photo.delchatPic();
							Toast.makeText(
									SystemSetupClearTalkInfoActivity.this,
									"成功清除本地聊天记录", Toast.LENGTH_SHORT).show();
						}
					}
				});

	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {

		/*
		 * case R.id.msg_modifypwd://点击修改密码 break;
		 */
		}
	}

	@Override
	public boolean dispatchKeyEvent(KeyEvent event) {
		if (event.getAction() == KeyEvent.ACTION_DOWN
				&& event.getKeyCode() == KeyEvent.KEYCODE_BACK
				&& event.getRepeatCount() == 0) {
			onBackPressed();
			return true;
		}
		return super.dispatchKeyEvent(event);
	}

}
